Bitcoin VWAP Calculation¶

Import¶

In [ ]:
! pip install -r ../requirements.txt
In [15]:
import os
from datetime import datetime 
import numpy as np
import pandas as pd
from IPython.display import display, clear_output, HTML
import plotly.graph_objects as go

Data Import¶

In [16]:
def load_data_from_csv():
    """
    Load CSV files from the 'data' directory into a dictionary of DataFrames.
    Each DataFrame is named according to the corresponding CSV file name with a "df_" prefix.
    
    Returns:
        dict: Dictionary of DataFrames with 'df_' prefixed names.
    """
    notebook_dir = os.getcwd()
    data_dir = os.path.join(notebook_dir, "../data")
    csv_files = os.listdir(data_dir)

    dataframes_dict = {}

    for file in csv_files:
        if file.endswith('.csv'):
            file_path = os.path.join(data_dir, file)
            df = pd.read_csv(file_path)
            file_name = os.path.splitext(file)[0]
            dataframes_dict['df_' + str(file_name)] = df
            df['timestamp'] = pd.to_datetime(df['timestamp'])

            print(f"df_{file_name}")
            print(df.head(3))
            print("\n")

    return dataframes_dict

dataframes_dict = load_data_from_csv()
df_stmp
            timestamp    price  amount
0 2021-02-24 23:59:54  49754.0   0.753
1 2021-02-24 23:59:52  49754.0   0.116
2 2021-02-24 23:59:52  49754.0   0.104


df_lmax
                timestamp    price  amount
0 2021-02-24 23:59:59.691  49767.0    0.01
1 2021-02-24 23:59:42.786  49752.0    0.06
2 2021-02-24 23:59:42.785  49752.0    0.30


df_gmni
                timestamp     price    amount
0 2021-02-24 23:59:53.406  49773.07  0.003435
1 2021-02-24 23:59:53.406  49766.06  0.051690
2 2021-02-24 23:59:47.280  49746.16  0.122833


df_itbi
                timestamp     price  amount
0 2021-02-24 23:59:48.157  49753.50  0.0001
1 2021-02-24 23:59:45.463  49753.75  0.0004
2 2021-02-24 23:59:38.887  49734.50  0.0001


df_okcn
                timestamp     price  amount
0 2021-02-24 23:59:57.847  49724.93    0.02
1 2021-02-24 23:59:49.743  49730.33    0.02
2 2021-02-24 23:59:35.623  49706.87    0.02


df_bfnx
                timestamp    price  amount
0 2021-02-24 23:59:58.181  49716.0   0.010
1 2021-02-24 23:59:58.176  49713.0   0.005
2 2021-02-24 23:59:51.526  49715.0   0.005


df_btrx
                timestamp      price    amount
0 2021-02-24 23:59:48.910  49742.749  0.001054
1 2021-02-24 23:59:35.050  49734.460  0.009038
2 2021-02-24 23:59:34.110  49751.270  0.000386


df_bfly
                timestamp     price  amount
0 2021-02-24 23:59:33.720  49712.15  0.0054
1 2021-02-24 23:44:16.980  49603.44  0.0770
2 2021-02-24 22:32:39.320  48864.19  0.1200


df_bnus
                timestamp     price    amount
0 2021-02-24 23:59:58.164  49714.50  0.004413
1 2021-02-24 23:59:57.547  49727.83  0.001496
2 2021-02-24 23:59:57.244  49727.83  0.002597


df_cbse
                timestamp     price   amount
0 2021-02-24 23:59:59.873  49737.82  0.00144
1 2021-02-24 23:59:59.721  49737.82  0.00037
2 2021-02-24 23:59:59.121  49737.82  0.00294


df_krkn
                timestamp    price    amount
0 2021-02-24 23:59:58.649  49727.7  0.000225
1 2021-02-24 23:59:49.807  49739.9  0.000224
2 2021-02-24 23:59:43.159  49736.3  0.014493


Data Transformation¶

1) Creation of a dataframe 'df_all' and integration into the dictionary¶

In [17]:
def global_df_creation(dataframes_dict):
    """
    Concatenates all DataFrames in the provided dictionary and returns a new dictionary 
    containing the concatenated DataFrame under the key 'df_all'.
    
    Args:
    - dataframes_dict (dict): A dictionary where values are DataFrames to be concatenated.
    
    Returns:
    - dict: A dictionary containing all original DataFrames along with the concatenated one ('df_all').
    """
    
    dfs_to_concat = list(dataframes_dict.values())  # Identify the DataFrames to concatenate
    print(f"Concatenating DataFrames:\n{list(dataframes_dict)}\n")
    
    # Perform vertical concatenation without losing data, reset index for unique transaction keys
    df_all = pd.concat(dfs_to_concat, ignore_index=True)
    print("'df_all':")
    display(df_all)  # Verification: check if duplicates like '2021-02-24 23:59:52.000' appear twice (indicating transactions retained)
    
    # Create a copy of the original dictionary and add the concatenated DataFrame
    all_dataframes_dict = dataframes_dict.copy()
    all_dataframes_dict['df_all'] = df_all
    print(f"Integration into the dictionary 'all_dataframes_dict':\n{list(all_dataframes_dict)}\n")  # Verification
    
    return all_dataframes_dict

all_dataframes_dict = global_df_creation(dataframes_dict)
Concatenating DataFrames:
['df_stmp', 'df_lmax', 'df_gmni', 'df_itbi', 'df_okcn', 'df_bfnx', 'df_btrx', 'df_bfly', 'df_bnus', 'df_cbse', 'df_krkn']

'df_all':
timestamp price amount
0 2021-02-24 23:59:54.000 49754.0 0.753000
1 2021-02-24 23:59:52.000 49754.0 0.116000
2 2021-02-24 23:59:52.000 49754.0 0.104000
3 2021-02-24 23:59:49.000 49754.0 0.016000
4 2021-02-24 23:59:45.000 49754.0 0.011000
... ... ... ...
1136788 2021-02-24 00:00:11.182 48899.8 0.023270
1136789 2021-02-24 00:00:10.373 48899.9 0.200000
1136790 2021-02-24 00:00:07.818 48899.9 0.018278
1136791 2021-02-24 00:00:02.351 48899.9 0.002045
1136792 2021-02-24 00:00:01.115 48899.6 0.018780

1136793 rows × 3 columns

Integration into the dictionary 'all_dataframes_dict':
['df_stmp', 'df_lmax', 'df_gmni', 'df_itbi', 'df_okcn', 'df_bfnx', 'df_btrx', 'df_bfly', 'df_bnus', 'df_cbse', 'df_krkn', 'df_all']

CALCULATION¶

1) Definition of calculation parameters¶

In [18]:
def get_frequency():
    """
    Prompts the user to input a frequency (in minutes) and returns it as a string in the format "{value}min".
    
    Returns:
    - str: The frequency entered by the user, formatted as "{value}min".
    """
    while True:
        try:
            frequency_input = input("Please enter a numeric value for the frequency (in minutes): ")
            frequency = int(frequency_input)
            frequency_str = str(frequency) + 'min'
            return frequency_str
        
        except ValueError:
            print("Error: Please enter a valid numeric value.")


def get_vwmp_type():
    """
    Prompts the user to input the type of VWMP calculation ('lower' or 'upper').
    
    Returns:
    - str: The VWMP type entered by the user ('lower' or 'upper').
    """
    while True:
        vwmp_type = input("Please enter 'lower' or 'upper' for the VWMP calculation: ").lower()
        if vwmp_type in ['lower', 'upper']:
            return vwmp_type
        
        else:
            print("Error: Please enter 'lower' or 'upper'.")

2) Aggregation and calculation of data according to selected parameters¶

In [19]:
def process_data(all_dataframes_dict, frequency, vwmp_type):
    """
    Processes the data by aggregating, calculating metrics, cleaning, and compiling results.
    
    Args:
    - all_dataframes_dict (dict): A dictionary of DataFrames for each exchange.
    - frequency (str): The frequency for data aggregation (e.g., '5min').
    - vwmp_type (str): The type of VWMP calculation ('lower' or 'upper').

    Returns:
    - tuple: A tuple containing dictionaries of aggregated, calculated, cleaned, and compiled data.
    """
    
    print(f"Selected frequency: {frequency}")
    print(f"Selected VWMP calculation: {vwmp_type}")
    print("\n...calculation in progress")
    
    # Initialize dictionaries to store intermediate results
    aggregated_dict = {}
    calculated_dict = {}
    cleaned_dict = {}
    compilated_dict = {}

    for key, df in all_dataframes_dict.items():
        exchange_name = (str(key)).split("df_")[1]
        
        # Step 1: Aggregate the data
        aggregated_df = aggregate_data(df, frequency)
        aggregated_dict[key] = aggregated_df 
        
        # Step 2: Calculate metrics
        calculated_df = calculate_metrics(df, frequency, vwmp_type, aggregated_df, exchange_name)
        calculated_dict[key] = calculated_df 
        
        # Step 3: Clean the data
        cleaned_df = clean_data(calculated_df, exchange_name)
        cleaned_dict[key] = cleaned_df

    # Step 4: Compile the results
    compilated_dict = compilate_data(cleaned_dict, vwmp_type)
    
    clear_output()
    print("Calculation completed!\n")
    print(f"Aggregation frequency: {frequency}")
    print(f"VWMP calculation: {vwmp_type}")
    
    return aggregated_dict, calculated_dict, cleaned_dict, compilated_dict


def aggregate_data(df, frequency):
    """
    Aggregates the initial data by calculating price, amount, and weighted volume.
    
    Args:
    - df (DataFrame): The original DataFrame to be aggregated.
    - frequency (str): The frequency for data aggregation (e.g., '5min').

    Returns:
    - DataFrame: The aggregated DataFrame.
    """
    
    # Calculate the weighted volume for each transaction
    df['weighted_volume'] = (df['price'] * df['amount'])
    
    # Perform aggregation by the specified frequency
    aggregated_df = df.groupby(pd.Grouper(key='timestamp', freq=frequency)).agg({
        'price': ['sum', 'first', 'max', 'min', 'last'],
        'amount': 'sum',
        'weighted_volume': 'sum'
    })
    
    # Rename columns for clarity
    aggregated_df.columns = [
        'price', 'price_open', 'price_high', 'price_low', 'price_close', 'amount', 'weighted_volume'
    ]
    
    return aggregated_df


def calculate_metrics(df, frequency, vwmp_type, aggregated_df, exchange_name):
    """
    Calculates the VWAP, VWMP, and standard deviation for each aggregated period.
    
    Args:
    - df (DataFrame): The original DataFrame.
    - frequency (str): The frequency for data aggregation (e.g., '5min').
    - vwmp_type (str): The type of VWMP calculation ('lower' or 'upper').
    - aggregated_df (DataFrame): The aggregated DataFrame.
    - exchange_name (str): The name of the exchange.

    Returns:
    - DataFrame: The DataFrame with calculated metrics.
    """
    
    # Copy the aggregated DataFrame for further calculations
    calculated_df = aggregated_df.copy()
    
    # Calculate VWAP, standard deviation, and VWMP (lower or upper)
    calculated_df[f'{exchange_name}_vwap'] = df.groupby(pd.Grouper(key='timestamp', freq=frequency)).apply(calculate_vwap)
    calculated_df['sigma'] = df.groupby(pd.Grouper(key='timestamp', freq=frequency)).apply(calculate_ecart_type)
    calculated_df[f'{exchange_name}_vwmp ({vwmp_type})'] = df.groupby(pd.Grouper(key='timestamp', freq=frequency)).apply(
        lambda group: pd.Series(calculate_vwmp(group, vwmp_type))
    )
    
    return calculated_df


def calculate_vwap(group):
    """
    Calculates the Volume Weighted Average Price (VWAP) for a group of transactions.
    
    Args:
    - group (DataFrame): A group of transactions for a specific time period.

    Returns:
    - float: The calculated VWAP.
    """
    
    sum_price_amount = group['weighted_volume'].sum()
    sum_amount = group['amount'].sum()

    return (sum_price_amount / sum_amount) if sum_amount != 0 else 0


def calculate_ecart_type(group):
    """
    Calculates the standard deviation (sigma) of the price for a group of transactions.
    
    Args:
    - group (DataFrame): A group of transactions for a specific time period.

    Returns:
    - float: The calculated standard deviation.
    """
    
    ecart_type = np.nanstd(group['price'])
    return ecart_type if ecart_type != np.nan else 0


def calculate_vwmp(group, vwmp_type):
    """
    Calculates the Volume Weighted Median Price (VWMP) for a group of transactions.
    
    Args:
    - group (DataFrame): A group of transactions for a specific time period.
    - vwmp_type (str): The type of VWMP calculation ('lower' or 'upper').

    Returns:
    - float: The calculated VWMP (either lower or upper).
    """
    
    series_sorted = group.sort_values('amount')
    series_sorted['cumul_amount'] = series_sorted['amount'].cumsum()
    total_volume_median = series_sorted['cumul_amount'].max() / 2

    # - -- - symmetry

    if vwmp_type == 'lower':
        lower_cumulative_volume = series_sorted[series_sorted['cumul_amount'] <= total_volume_median]
        
        if not lower_cumulative_volume.empty:
            max_cumul_amount_index = lower_cumulative_volume['cumul_amount'].idxmax()
            vwmp_lower = group.loc[max_cumul_amount_index, 'price']
            return round(vwmp_lower, 2)
        else:
            return group['price'].mean()
        
    #-- - -- - -- - -- - -- - -- - -- - -- - -- - -- - -- - -- - -- - -- - -- - -- - -- - -- - -- - -- - #symmetry
    
    if vwmp_type == 'upper':
        upper_cumulative_volume = series_sorted[series_sorted['cumul_amount'] <= total_volume_median]
        
        if not upper_cumulative_volume.empty:
            min_cumul_amount_index = upper_cumulative_volume['cumul_amount'].idxmin()
            vwmp_upper = group.loc[min_cumul_amount_index, 'price']
            return round(vwmp_upper, 2)
        else:
            return group['price'].mean()
        
    # - -- - symmetry
    
    raise ValueError("Invalid mode. Please specify 'lower' or 'upper'.")


def clean_data(calculated_df, exchange_name):
    """
    Cleans the calculated DataFrame by formatting the columns and removing rows with all zero or null values.
    
    Args:
    - calculated_df (DataFrame): The DataFrame containing calculated metrics.
    - exchange_name (str): The name of the exchange.

    Returns:
    - DataFrame: The cleaned DataFrame.
    """
    
    cleaned_df = calculated_df.copy()
    
    # Round and format the columns
    cleaned_df['price'] = round((cleaned_df['price'] / 1000000000), 2)
    cleaned_df.rename(columns={'price': 'Price [Md€]'}, inplace=True)
    
    cleaned_df['amount'] = round(cleaned_df['amount'], 2)
    cleaned_df.rename(columns={'amount': 'Amount [BTC]'}, inplace=True)
    
    cleaned_df['sigma'] = round(cleaned_df['sigma'], 2)
    
    cleaned_df[f'{exchange_name}_vwap'] = round(cleaned_df[f'{exchange_name}_vwap'], 2)
    
    # Remove rows where all values are zero or null
    cleaned_df = cleaned_df[~cleaned_df.apply(
        lambda row: all(val == 0.0 or pd.isnull(val) for val in row), axis=1
    )]
    
    return cleaned_df


def compilate_data(cleaned_dict, vwmp_type):
    """
    Compiles the results into summary DataFrames for VWAP and VWMP.

    Args:
    - cleaned_dict (dict): A dictionary of cleaned DataFrames for each exchange.
    - vwmp_type (str): The type of VWMP calculation ('lower' or 'upper').

    Returns:
    - dict: A dictionary containing the compiled VWAP and VWMP summary DataFrames.
    """
    
    df_synthese_vwap = None
    df_synthese_vwmp = None
    
    # Compile VWAP data
    for key, df in cleaned_dict.items():
        exchange_name = (str(key)).split("df_")[1]
        
        if f'{exchange_name}_vwap' in df.columns:
            vwap_column = df[f'{exchange_name}_vwap']
            
            if df_synthese_vwap is None:
                df_synthese_vwap = vwap_column.to_frame()
            else:
                df_synthese_vwap = pd.concat([df_synthese_vwap, vwap_column], axis=1)

    # Compile VWMP data
    for key, df in cleaned_dict.items():
        exchange_name = (str(key)).split("df_")[1]
        
        if f'{exchange_name}_vwmp ({vwmp_type})' in df.columns:
            vwmp_column = df[f'{exchange_name}_vwmp ({vwmp_type})']
            
            if df_synthese_vwmp is None:
                df_synthese_vwmp = vwmp_column.to_frame()
            else:
                df_synthese_vwmp = pd.concat([df_synthese_vwmp, vwmp_column], axis=1)
    
    compilated_dict = cleaned_dict.copy()
    compilated_dict['df_synthese_vwap'] = df_synthese_vwap
    compilated_dict['df_synthese_vwmp'] = df_synthese_vwmp
    
    return compilated_dict

3) Data Vizualisation¶

In [20]:
def visualisation(cleaned_dict, max_table_height, max_visible_rows):
    """
    Visualizes a dictionary of dataframes with candlestick plots and VWAP charts.
    Displays each dataframe as a table and a plot, with customizable table height and visible rows.

    Parameters:
        cleaned_dict (dict): Dictionary where the key is the exchange name and value is the dataframe.
        max_table_height (int): Maximum height of the table in the HTML output.
        max_visible_rows (int): Number of rows to display in the table.
    """
    
    for key, df in reversed(list(cleaned_dict.items())):
        exchange_name = key.split("df_")[1]  # Extract exchange name from the key
        vwmp_column_index = 9  # Index of the 'vwmp' column (constant)
        
        # Create candlestick plot
        candlestick = go.Figure(data=[go.Candlestick(
            x=df.index,
            open=df['price_open'],
            high=df['price_high'],
            low=df['price_low'],
            close=df['price_close']
        )])

        # Update the layout of the candlestick plot
        candlestick.update_layout(
            title=f'BTC-EUR [{exchange_name}]',
            yaxis_title='Price',
            height=300,  # Height of the plot
            width=700,   # Width of the plot
            margin=dict(l=20, r=10, t=50, b=20),  # Plot margins
            plot_bgcolor='#F5F5F5',  # Background color of the plot
        )
        
        # Add VWAP trace (Volume Weighted Average Price)
        candlestick.add_trace(go.Scatter(
            x=df.index, 
            y=df[f'{exchange_name}_vwap'], 
            mode='lines', 
            name='vwap', 
            line_color='black'
        ))
        
        # Add VWMP (Volume Weighted Market Price) trace
        candlestick.add_trace(go.Scatter(
            x=df.index, 
            y=df.iloc[:, vwmp_column_index], 
            mode='lines', 
            name=df.columns[vwmp_column_index], 
            line_color='grey'
        ))
        
        # Convert the candlestick plot to HTML
        graph_html = candlestick.to_html(full_html=False, include_plotlyjs=True)
        
        # Define the columns to display in the table
        selected_columns = [0, 5, 7, 9, 8]
        df_selected = df.iloc[:, selected_columns].head(max_visible_rows)  # Filter the dataframe for display
        table_html = df_selected.to_html(
            index=True, 
            classes=f'scrollable-table-container-{exchange_name}', 
            max_rows=len(df_selected)
        )  # Convert dataframe to HTML table

        # Combine HTML for table and graph display
        html_output = f"""
            <div style="display: flex; flex-direction: row;">
                <div style="width: 45%; max-height: {max_table_height}px; overflow-y: auto;">
                    <h2 style="position: sticky; top: 0;">{exchange_name} exchange</h2>
                    <div style="overflow-x: auto;">
                        {table_html}
                    </div>
                </div>
                <div style="width: 55%; overflow: hidden;">{graph_html}</div>
            </div>
        """
        
        # Display the HTML output (table + graph)
        display(HTML(html_output))

4) Export in csv files¶

In [21]:
def export_csv(compilated_dict, frequency, vwmp_type):
    """
    Exports each DataFrame in the given dictionary to a CSV file in a newly created directory.

    Args:
        compilated_dict (dict): Dictionary where keys are file names and values are DataFrames.
        frequency (str): Frequency parameter to be included in the export folder name.
        vwmp_type (str): VWMP type parameter to be included in the export folder name.

    Returns:
        bool: True if export was successful, False otherwise.
    """
    
    # Get the current working directory and generate a timestamp
    notebook_dir = os.getcwd()
    now = datetime.now().strftime("%Y-%m-%d_%H-%M-%S")

    # Create the export folder path
    export_folder = os.path.join(notebook_dir, f'../output/Export_{now}_freq-{frequency}_vwmp-{vwmp_type}')
    
    # Create the export directory
    os.makedirs(export_folder, exist_ok=True)

    export_success = False

    try:
        # Iterate over the DataFrame dictionary and export each to a CSV
        for key, df in compilated_dict.items():
            filename = f"{key}.csv"        # Define the filename
            file_path = os.path.join(export_folder, filename)  # Full path for the file
            df.to_csv(file_path, index=True)  # Export DataFrame to CSV

        export_success = True
        print(f"CSV files exported successfully:\n\n --> {export_folder}\n")
        return export_success

    except Exception as e:
        print(f"Error during export: {e}")
        return export_success

RESULTS¶

1) To define the calculation parameters and launch the data aggregation:¶

In [22]:
frequency = get_frequency()  # Choose the aggregation interval
vwmp_type = get_vwmp_type()  # Choose the VWMP calculation type (lower or upper)

aggregated_dict, calculated_dict, cleaned_dict, compilated_dict = process_data( # Process the data 
    all_dataframes_dict, frequency, vwmp_type
)  
Calculation completed!

Aggregation frequency: 60min
VWMP calculation: lower

2) To Vizualise results:¶

In [23]:
visualisation(cleaned_dict, max_table_height=300, max_visible_rows=1000)

all exchange

Price [Md€] Amount [BTC] all_vwap all_vwmp (lower) sigma
timestamp
2021-02-24 00:00:00 3.26 4523.86 47882.88 48888.00 538.75
2021-02-24 01:00:00 3.48 4839.06 49313.37 48946.35 454.07
2021-02-24 02:00:00 3.43 4407.16 50244.17 50075.50 175.54
2021-02-24 03:00:00 2.45 3075.41 50513.87 50314.07 223.79
2021-02-24 04:00:00 2.81 4002.54 50927.85 50500.00 244.42
2021-02-24 05:00:00 2.13 2619.76 50455.61 50539.68 265.89
2021-02-24 06:00:00 2.50 3642.08 49913.41 49873.16 318.53
2021-02-24 07:00:00 1.54 1563.61 49962.54 49747.64 202.58
2021-02-24 08:00:00 1.95 2624.78 50578.67 50200.00 237.27
2021-02-24 09:00:00 2.00 2571.31 50911.78 50920.00 247.13
2021-02-24 10:00:00 1.88 2481.39 50534.98 50550.00 223.86
2021-02-24 11:00:00 1.47 1728.40 50499.33 50759.00 174.59
2021-02-24 12:00:00 2.13 3253.18 50934.17 51143.49 223.75
2021-02-24 13:00:00 3.55 6518.15 49799.74 49475.00 489.05
2021-02-24 14:00:00 2.75 3816.09 49263.85 48813.74 242.49
2021-02-24 15:00:00 3.04 3969.26 49203.58 48550.00 373.52
2021-02-24 16:00:00 2.12 2521.59 49750.27 49400.00 179.23
2021-02-24 17:00:00 1.69 1906.49 49822.59 49733.00 139.79
2021-02-24 18:00:00 1.66 1950.77 49798.92 49648.40 133.53
2021-02-24 19:00:00 2.09 2718.66 49268.92 49506.05 241.39
2021-02-24 20:00:00 2.11 2818.38 48929.22 48978.19 170.44
2021-02-24 21:00:00 2.30 3016.12 48487.35 48594.54 244.46
2021-02-24 22:00:00 1.96 1903.59 48574.60 48702.42 235.69
2021-02-24 23:00:00 2.25 2683.43 49438.25 49821.30 206.19

krkn exchange

Price [Md€] Amount [BTC] krkn_vwap krkn_vwmp (lower) sigma
timestamp
2021-02-24 00:00:00 0.22 484.20 47698.31 48300.0 423.74
2021-02-24 01:00:00 0.24 575.52 49179.03 49302.5 472.31
2021-02-24 02:00:00 0.22 484.47 50214.50 50044.8 191.75
2021-02-24 03:00:00 0.13 297.82 50537.04 50306.2 234.82
2021-02-24 04:00:00 0.18 395.69 50917.06 50860.4 245.54
2021-02-24 05:00:00 0.11 204.31 50421.09 50282.4 257.70
2021-02-24 06:00:00 0.18 458.50 49916.11 49613.0 300.56
2021-02-24 07:00:00 0.12 237.82 49994.27 50146.8 199.48
2021-02-24 08:00:00 0.16 314.73 50545.22 49922.9 228.70
2021-02-24 09:00:00 0.17 280.46 50987.74 51143.6 247.93
2021-02-24 10:00:00 0.17 247.90 50643.54 50575.0 219.04
2021-02-24 11:00:00 0.09 176.95 50523.50 50601.3 163.52
2021-02-24 12:00:00 0.11 222.83 50864.10 50877.2 228.55
2021-02-24 13:00:00 0.26 600.06 49743.21 49241.8 449.55
2021-02-24 14:00:00 0.20 540.26 49223.09 49615.1 245.17
2021-02-24 15:00:00 0.19 424.77 49217.79 49365.4 364.26
2021-02-24 16:00:00 0.12 235.53 49749.96 49487.1 188.77
2021-02-24 17:00:00 0.09 210.39 49842.35 49812.9 132.21
2021-02-24 18:00:00 0.08 178.81 49813.10 49751.0 140.61
2021-02-24 19:00:00 0.11 231.15 49230.39 49413.6 241.03
2021-02-24 20:00:00 0.13 306.18 48964.87 48846.0 169.65
2021-02-24 21:00:00 0.19 434.60 48499.38 48581.7 243.11
2021-02-24 22:00:00 0.12 196.80 48540.35 48466.9 253.29
2021-02-24 23:00:00 0.14 370.42 49459.91 49369.9 212.59

cbse exchange

Price [Md€] Amount [BTC] cbse_vwap cbse_vwmp (lower) sigma
timestamp
2021-02-24 00:00:00 1.45 1968.97 47945.34 48577.20 525.15
2021-02-24 01:00:00 1.52 1900.25 49317.20 48703.58 443.30
2021-02-24 02:00:00 1.74 1904.70 50248.89 50078.86 175.48
2021-02-24 03:00:00 1.29 1350.36 50498.14 50466.57 216.81
2021-02-24 04:00:00 1.35 1920.44 50942.65 50668.33 239.30
2021-02-24 05:00:00 0.91 1047.17 50513.99 50830.63 257.94
2021-02-24 06:00:00 0.96 1077.13 49982.47 50170.68 306.34
2021-02-24 07:00:00 0.58 498.93 49959.62 50255.06 191.18
2021-02-24 08:00:00 0.60 503.58 50541.09 50184.44 228.41
2021-02-24 09:00:00 0.67 551.97 50901.00 50820.01 244.50
2021-02-24 10:00:00 0.60 779.47 50523.89 50498.84 204.92
2021-02-24 11:00:00 0.59 561.86 50498.46 50239.09 172.94
2021-02-24 12:00:00 0.85 1149.14 50935.79 51108.72 226.01
2021-02-24 13:00:00 1.28 2158.87 49811.47 49762.17 491.19
2021-02-24 14:00:00 1.14 1316.22 49293.35 49503.71 237.80
2021-02-24 15:00:00 1.34 1792.01 49224.86 49492.63 359.76
2021-02-24 16:00:00 0.96 1160.92 49748.95 49717.89 162.19
2021-02-24 17:00:00 0.85 880.59 49813.53 49837.46 139.09
2021-02-24 18:00:00 0.84 975.31 49790.61 49703.37 133.26
2021-02-24 19:00:00 0.96 1273.65 49259.86 49000.00 241.39
2021-02-24 20:00:00 0.96 1408.39 48922.87 48977.24 165.76
2021-02-24 21:00:00 1.01 1256.83 48476.88 48641.53 245.53
2021-02-24 22:00:00 0.97 916.80 48579.18 48568.00 220.53
2021-02-24 23:00:00 0.89 987.01 49428.97 49227.93 212.73

bnus exchange

Price [Md€] Amount [BTC] bnus_vwap bnus_vwmp (lower) sigma
timestamp
2021-02-24 00:00:00 0.14 127.85 47846.76 47900.00 558.40
2021-02-24 01:00:00 0.16 124.06 49196.19 49234.79 443.72
2021-02-24 02:00:00 0.15 112.74 50200.41 50276.62 178.43
2021-02-24 03:00:00 0.10 79.40 50523.29 50211.69 209.43
2021-02-24 04:00:00 0.15 122.81 50900.80 51075.09 235.42
2021-02-24 05:00:00 0.09 65.64 50383.99 50099.92 260.79
2021-02-24 06:00:00 0.11 105.03 50046.49 50439.66 330.84
2021-02-24 07:00:00 0.05 47.71 49861.58 49557.00 198.83
2021-02-24 08:00:00 0.08 54.41 50559.89 50868.01 210.12
2021-02-24 09:00:00 0.11 74.38 50842.08 50959.97 229.44
2021-02-24 10:00:00 0.08 45.36 50515.87 50305.70 221.38
2021-02-24 11:00:00 0.07 26.54 50475.34 50285.31 163.79
2021-02-24 12:00:00 0.09 33.33 50870.86 50702.44 244.83
2021-02-24 13:00:00 0.16 119.53 49783.08 49755.51 485.86
2021-02-24 14:00:00 0.13 98.65 49251.72 49288.47 235.02
2021-02-24 15:00:00 0.17 114.23 49258.31 49100.00 341.36
2021-02-24 16:00:00 0.12 58.50 49765.88 49390.69 187.04
2021-02-24 17:00:00 0.09 31.94 49808.54 49715.61 141.56
2021-02-24 18:00:00 0.08 27.89 49795.33 49919.01 138.87
2021-02-24 19:00:00 0.10 85.43 49355.11 49611.00 247.56
2021-02-24 20:00:00 0.11 50.21 48906.48 49100.01 169.19
2021-02-24 21:00:00 0.11 40.99 48485.98 48365.67 234.13
2021-02-24 22:00:00 0.08 31.98 48549.93 48724.33 222.10
2021-02-24 23:00:00 0.13 54.61 49399.63 49568.70 193.27

bfly exchange

Price [Md€] Amount [BTC] bfly_vwap bfly_vwmp (lower) sigma
timestamp
2021-02-24 00:00:00 0.0 1.96 48006.99 47743.62 495.20
2021-02-24 01:00:00 0.0 1.04 49607.92 49777.91 467.96
2021-02-24 02:00:00 0.0 1.77 50196.68 49994.55 130.52
2021-02-24 03:00:00 0.0 0.25 50948.00 50948.00 0.00
2021-02-24 04:00:00 0.0 0.77 50892.81 51025.46 140.00
2021-02-24 06:00:00 0.0 1.57 49978.51 50016.68 116.10
2021-02-24 07:00:00 0.0 0.03 49680.10 49680.10 0.00
2021-02-24 08:00:00 0.0 0.79 50144.21 50410.65 330.03
2021-02-24 09:00:00 0.0 0.35 50884.02 50900.00 23.47
2021-02-24 10:00:00 0.0 0.14 50536.60 50486.11 29.08
2021-02-24 11:00:00 0.0 0.27 50474.18 50500.00 90.65
2021-02-24 12:00:00 0.0 0.12 51228.62 51078.18 75.85
2021-02-24 13:00:00 0.0 3.89 49681.73 50116.80 447.97
2021-02-24 14:00:00 0.0 1.40 49266.09 49200.75 213.65
2021-02-24 15:00:00 0.0 2.36 48785.15 48631.44 275.78
2021-02-24 16:00:00 0.0 0.89 49645.48 49766.55 249.39
2021-02-24 17:00:00 0.0 0.08 49714.25 49731.74 28.22
2021-02-24 18:00:00 0.0 0.12 49602.44 49700.00 50.00
2021-02-24 19:00:00 0.0 0.47 49191.60 49444.96 214.42
2021-02-24 20:00:00 0.0 1.51 48991.42 48909.50 131.93
2021-02-24 21:00:00 0.0 1.12 48404.53 48272.99 161.04
2021-02-24 22:00:00 0.0 1.72 48270.60 48247.38 164.85
2021-02-24 23:00:00 0.0 0.08 49610.56 49712.15 54.35

btrx exchange

Price [Md€] Amount [BTC] btrx_vwap btrx_vwmp (lower) sigma
timestamp
2021-02-24 00:00:00 0.08 42.47 47861.25 48144.74 557.62
2021-02-24 01:00:00 0.10 55.04 49343.27 49880.70 469.53
2021-02-24 02:00:00 0.07 32.53 50264.13 50283.49 175.98
2021-02-24 03:00:00 0.05 38.11 50528.68 50488.86 194.34
2021-02-24 04:00:00 0.05 29.55 50914.28 50814.88 232.90
2021-02-24 05:00:00 0.06 32.88 50537.36 50136.44 267.32
2021-02-24 06:00:00 0.08 38.28 50033.77 49823.59 325.17
2021-02-24 07:00:00 0.04 19.92 50032.96 50250.00 185.50
2021-02-24 08:00:00 0.07 34.80 50587.22 50659.68 223.99
2021-02-24 09:00:00 0.08 35.10 50947.53 51273.56 264.03
2021-02-24 10:00:00 0.05 20.41 50665.39 50964.17 249.32
2021-02-24 11:00:00 0.05 18.75 50556.42 50398.54 186.04
2021-02-24 12:00:00 0.05 23.61 50907.73 50640.75 219.33
2021-02-24 13:00:00 0.10 63.35 49839.74 49365.90 478.70
2021-02-24 14:00:00 0.07 36.01 49311.93 48825.47 258.33
2021-02-24 15:00:00 0.06 37.28 49280.56 49067.10 348.01
2021-02-24 16:00:00 0.04 29.10 49805.94 49817.22 167.60
2021-02-24 17:00:00 0.03 17.65 49786.38 49879.22 126.27
2021-02-24 18:00:00 0.03 21.01 49797.74 49775.66 122.40
2021-02-24 19:00:00 0.03 17.74 49257.82 49000.00 254.68
2021-02-24 20:00:00 0.03 16.05 48907.01 48982.99 170.82
2021-02-24 21:00:00 0.05 33.35 48486.39 48356.22 234.45
2021-02-24 22:00:00 0.03 15.57 48566.46 48752.87 230.19
2021-02-24 23:00:00 0.04 33.44 49488.22 49750.00 223.02

bfnx exchange

Price [Md€] Amount [BTC] bfnx_vwap bfnx_vwmp (lower) sigma
timestamp
2021-02-24 00:00:00 0.94 626.71 47778.97 48625.00 559.38
2021-02-24 01:00:00 1.05 899.69 49441.59 49834.00 459.52
2021-02-24 02:00:00 0.82 756.81 50237.01 50388.00 169.19
2021-02-24 03:00:00 0.56 503.34 50608.44 50534.00 244.93
2021-02-24 04:00:00 0.71 565.68 50889.74 50919.00 248.17
2021-02-24 05:00:00 0.63 502.86 50344.15 50420.00 274.02
2021-02-24 06:00:00 0.80 899.86 49713.51 49662.00 329.18
2021-02-24 07:00:00 0.53 267.21 49899.14 49639.00 218.46
2021-02-24 08:00:00 0.71 739.58 50629.72 50600.00 253.98
2021-02-24 09:00:00 0.65 736.83 50887.44 50800.00 244.13
2021-02-24 10:00:00 0.70 624.34 50480.38 50441.00 216.14
2021-02-24 11:00:00 0.42 219.14 50494.05 50410.00 172.09
2021-02-24 12:00:00 0.64 539.50 50976.88 51125.00 220.79
2021-02-24 13:00:00 1.06 917.79 49701.26 49516.00 494.14
2021-02-24 14:00:00 0.71 425.08 49233.19 48778.46 247.35
2021-02-24 15:00:00 0.84 613.93 49011.13 49062.00 400.27
2021-02-24 16:00:00 0.53 287.00 49734.68 49757.00 205.89
2021-02-24 17:00:00 0.33 200.23 49788.34 50056.00 148.55
2021-02-24 18:00:00 0.32 101.34 49795.62 50060.00 125.73
2021-02-24 19:00:00 0.54 290.59 49214.86 49017.00 238.57
2021-02-24 20:00:00 0.54 260.78 48895.91 48755.00 179.25
2021-02-24 21:00:00 0.60 362.04 48440.91 48478.00 234.27
2021-02-24 22:00:00 0.47 272.83 48531.10 48765.00 263.52
2021-02-24 23:00:00 0.74 389.42 49385.75 49525.00 198.65

okcn exchange

Price [Md€] Amount [BTC] okcn_vwap okcn_vwmp (lower) sigma
timestamp
2021-02-24 00:00:00 0.03 51.32 47954.73 47800.70 531.46
2021-02-24 01:00:00 0.03 36.39 49422.82 48876.62 428.59
2021-02-24 02:00:00 0.03 35.84 50218.79 50392.72 163.36
2021-02-24 03:00:00 0.02 17.36 50435.24 50970.65 176.05
2021-02-24 04:00:00 0.02 23.77 51023.20 50770.00 228.36
2021-02-24 05:00:00 0.02 21.63 50399.46 50186.14 253.91
2021-02-24 06:00:00 0.03 36.78 49940.21 49689.23 284.46
2021-02-24 07:00:00 0.02 23.97 50030.40 49691.87 177.16
2021-02-24 08:00:00 0.03 23.65 50482.66 50555.45 241.39
2021-02-24 09:00:00 0.03 41.05 51005.57 51155.96 240.79
2021-02-24 10:00:00 0.03 16.34 50564.54 50615.59 195.49
2021-02-24 11:00:00 0.03 10.53 50556.76 50749.53 175.23
2021-02-24 12:00:00 0.03 28.40 50921.93 51113.47 216.31
2021-02-24 13:00:00 0.06 74.76 49953.17 50243.46 491.99
2021-02-24 14:00:00 0.03 23.04 49345.87 49607.48 228.37
2021-02-24 15:00:00 0.03 51.19 49288.11 48901.63 353.15
2021-02-24 16:00:00 0.03 31.88 49824.68 49543.42 182.31
2021-02-24 17:00:00 0.02 16.63 49817.80 49975.78 138.42
2021-02-24 18:00:00 0.02 19.73 49797.71 49830.01 143.39
2021-02-24 19:00:00 0.02 30.80 49343.11 49579.09 235.93
2021-02-24 20:00:00 0.02 18.32 48851.21 48800.00 166.40
2021-02-24 21:00:00 0.02 19.49 48451.59 48978.83 260.84
2021-02-24 22:00:00 0.02 14.67 48543.50 48590.32 219.03
2021-02-24 23:00:00 0.02 28.19 49568.86 49213.08 188.71

itbi exchange

Price [Md€] Amount [BTC] itbi_vwap itbi_vwmp (lower) sigma
timestamp
2021-02-24 00:00:00 0.08 27.30 47772.26 47233.50 517.57
2021-02-24 01:00:00 0.08 60.36 49509.70 49700.00 438.58
2021-02-24 02:00:00 0.08 39.22 50260.29 50325.00 169.19
2021-02-24 03:00:00 0.06 19.71 50533.80 50937.25 207.16
2021-02-24 04:00:00 0.07 37.39 51019.75 50754.50 228.21
2021-02-24 05:00:00 0.05 23.06 50416.28 50498.75 256.46
2021-02-24 06:00:00 0.05 56.62 49907.75 50047.00 311.51
2021-02-24 07:00:00 0.03 9.56 49944.96 49870.50 187.60
2021-02-24 08:00:00 0.04 7.37 50600.27 50461.75 216.75
2021-02-24 09:00:00 0.03 8.51 51014.43 50919.75 250.04
2021-02-24 10:00:00 0.04 9.21 50588.05 50600.00 206.41
2021-02-24 11:00:00 0.04 11.48 50500.80 50581.25 173.52
2021-02-24 12:00:00 0.06 17.93 50956.07 51082.25 230.70
2021-02-24 13:00:00 0.09 83.83 49790.03 49901.50 479.25
2021-02-24 14:00:00 0.08 20.60 49260.07 49561.50 221.10
2021-02-24 15:00:00 0.08 23.17 49062.98 48610.00 347.96
2021-02-24 16:00:00 0.08 29.23 49749.26 49761.25 157.07
2021-02-24 17:00:00 0.06 16.93 49815.87 49734.25 130.13
2021-02-24 18:00:00 0.06 14.03 49791.77 49788.25 135.74
2021-02-24 19:00:00 0.07 26.22 49411.33 49333.00 241.34
2021-02-24 20:00:00 0.06 14.08 48880.35 48940.25 161.42
2021-02-24 21:00:00 0.07 24.64 48526.43 48577.00 245.32
2021-02-24 22:00:00 0.06 11.66 48497.26 48759.50 227.28
2021-02-24 23:00:00 0.06 9.36 49493.10 49733.00 205.18

gmni exchange

Price [Md€] Amount [BTC] gmni_vwap gmni_vwmp (lower) sigma
timestamp
2021-02-24 00:00:00 0.14 183.68 47981.71 48315.26 562.22
2021-02-24 01:00:00 0.12 212.92 49458.08 49101.00 486.40
2021-02-24 02:00:00 0.12 142.22 50268.26 50365.39 181.45
2021-02-24 03:00:00 0.09 110.12 50494.40 50656.81 210.86
2021-02-24 04:00:00 0.11 127.85 50934.95 51134.86 232.08
2021-02-24 05:00:00 0.10 99.56 50528.60 50954.35 265.58
2021-02-24 06:00:00 0.13 110.87 49935.14 50092.00 281.93
2021-02-24 07:00:00 0.05 46.29 50034.86 50304.82 179.69
2021-02-24 08:00:00 0.04 51.37 50476.88 50665.68 231.86
2021-02-24 09:00:00 0.07 56.68 50901.64 51358.51 264.90
2021-02-24 10:00:00 0.07 65.25 50494.32 50514.91 187.27
2021-02-24 11:00:00 0.05 34.01 50446.88 50800.00 183.01
2021-02-24 12:00:00 0.08 89.79 50932.91 51042.65 227.95
2021-02-24 13:00:00 0.20 355.62 49750.22 50928.59 437.56
2021-02-24 14:00:00 0.16 229.38 49282.04 48923.27 242.14
2021-02-24 15:00:00 0.14 141.78 49249.51 49009.85 354.11
2021-02-24 16:00:00 0.09 80.68 49720.09 49702.40 179.10
2021-02-24 17:00:00 0.11 186.62 49843.67 49935.46 122.21
2021-02-24 18:00:00 0.09 160.80 49796.55 49622.28 136.54
2021-02-24 19:00:00 0.11 169.22 49204.73 49448.60 236.44
2021-02-24 20:00:00 0.12 179.94 48952.99 49162.11 162.27
2021-02-24 21:00:00 0.11 135.62 48526.70 48715.43 262.39
2021-02-24 22:00:00 0.08 107.57 48650.57 48821.93 237.71
2021-02-24 23:00:00 0.07 57.33 49457.50 49249.67 198.82

lmax exchange

Price [Md€] Amount [BTC] lmax_vwap lmax_vwmp (lower) sigma
timestamp
2021-02-24 00:00:00 0.08 695.04 47880.96 47299.0 587.13
2021-02-24 01:00:00 0.04 368.06 49250.83 49275.0 504.33
2021-02-24 02:00:00 0.07 418.18 50227.85 50341.0 169.86
2021-02-24 03:00:00 0.05 311.69 50458.46 50365.5 215.89
2021-02-24 04:00:00 0.06 383.13 50851.64 51249.0 279.32
2021-02-24 05:00:00 0.04 250.29 50473.96 50216.0 292.09
2021-02-24 06:00:00 0.06 490.79 50061.81 49878.5 327.86
2021-02-24 07:00:00 0.04 210.74 49996.28 49785.0 180.21
2021-02-24 08:00:00 0.07 336.10 50552.86 50870.5 217.85
2021-02-24 09:00:00 0.05 302.15 50934.15 50923.5 256.29
2021-02-24 10:00:00 0.03 285.36 50514.77 50589.0 210.86
2021-02-24 11:00:00 0.05 426.13 50505.69 50565.5 178.83
2021-02-24 12:00:00 0.09 758.09 50918.64 50739.5 190.46
2021-02-24 13:00:00 0.16 1429.77 49827.04 49144.5 486.66
2021-02-24 14:00:00 0.07 544.80 49274.41 49552.0 232.83
2021-02-24 15:00:00 0.07 429.48 49324.91 49787.0 362.94
2021-02-24 16:00:00 0.06 362.45 49755.52 49773.5 164.06
2021-02-24 17:00:00 0.04 213.36 49845.11 49850.0 124.16
2021-02-24 18:00:00 0.05 267.80 49796.55 49928.5 137.87
2021-02-24 19:00:00 0.04 329.03 49317.07 49423.5 237.09
2021-02-24 20:00:00 0.04 271.42 48952.61 48950.5 175.59
2021-02-24 21:00:00 0.05 396.30 48518.46 49126.0 268.81
2021-02-24 22:00:00 0.03 108.22 48645.53 48900.0 214.85
2021-02-24 23:00:00 0.06 410.17 49423.47 49277.5 193.49

stmp exchange

Price [Md€] Amount [BTC] stmp_vwap stmp_vwmp (lower) sigma
timestamp
2021-02-24 00:00:00 0.10 314.35 47944.26 47625.91 573.97
2021-02-24 01:00:00 0.14 605.73 49220.30 48915.44 435.34
2021-02-24 02:00:00 0.13 478.68 50283.56 50319.47 174.27
2021-02-24 03:00:00 0.09 347.24 50472.64 50898.12 207.25
2021-02-24 04:00:00 0.11 395.45 50987.94 50975.37 237.48
2021-02-24 05:00:00 0.11 372.36 50440.12 50215.15 233.72
2021-02-24 06:00:00 0.11 366.65 49939.78 50476.72 283.47
2021-02-24 07:00:00 0.08 201.41 49974.24 50171.00 185.89
2021-02-24 08:00:00 0.14 558.41 50594.39 50493.97 225.24
2021-02-24 09:00:00 0.14 483.82 50902.71 50582.27 235.97
2021-02-24 10:00:00 0.10 387.62 50590.39 50918.19 223.42
2021-02-24 11:00:00 0.08 242.73 50480.34 50556.91 174.35
2021-02-24 12:00:00 0.12 390.43 50947.57 50525.81 199.92
2021-02-24 13:00:00 0.18 710.69 49893.77 49440.35 551.15
2021-02-24 14:00:00 0.15 580.65 49236.20 48757.03 233.05
2021-02-24 15:00:00 0.13 339.08 49221.75 49463.39 366.79
2021-02-24 16:00:00 0.09 245.39 49757.70 50064.47 167.60
2021-02-24 17:00:00 0.06 132.07 49847.05 49812.89 151.52
2021-02-24 18:00:00 0.07 183.94 49838.08 50014.64 139.52
2021-02-24 19:00:00 0.10 264.36 49337.14 49084.18 234.32
2021-02-24 20:00:00 0.10 291.51 48927.91 49113.52 172.72
2021-02-24 21:00:00 0.10 311.15 48509.78 48320.00 268.55
2021-02-24 22:00:00 0.09 225.76 48580.63 48821.53 238.29
2021-02-24 23:00:00 0.10 343.38 49504.55 49493.89 197.91

3) To display the VWAP df summary:¶

In [24]:
df_synthese_vwap = compilated_dict['df_synthese_vwap']
df_head = df_synthese_vwap.head(10)

def highlight_min(s):
    """
    Highlights the minimum value in each row with a green background.
    Args:
        s (pandas.Series): A row from the DataFrame.
    Returns:
        list: A list of styles, with 'background-color: green' for the minimum value.
    """
    is_min = s == s.min()  # Identify the minimum value in the row
    return ['background-color: green' if v else '' for v in is_min]

# Apply the conditional styling to the top 10 rows of the DataFrame
styled_df = df_head.style.apply(highlight_min, axis=1)

# Convert the styled DataFrame to HTML and prepare the output
html_str = f"<h2>Results [VWAP]</h2>"  # Header for the HTML output
html_str += styled_df.to_html(classes='scrollable-table', justify='left', escape=False)

# Display the styled HTML DataFrame
display(HTML(html_str))

Results [VWAP]

  stmp_vwap lmax_vwap gmni_vwap itbi_vwap okcn_vwap bfnx_vwap btrx_vwap bfly_vwap bnus_vwap cbse_vwap krkn_vwap all_vwap
timestamp                        
2021-02-24 00:00:00 47944.260000 47880.960000 47981.710000 47772.260000 47954.730000 47778.970000 47861.250000 48006.990000 47846.760000 47945.340000 47698.310000 47882.880000
2021-02-24 01:00:00 49220.300000 49250.830000 49458.080000 49509.700000 49422.820000 49441.590000 49343.270000 49607.920000 49196.190000 49317.200000 49179.030000 49313.370000
2021-02-24 02:00:00 50283.560000 50227.850000 50268.260000 50260.290000 50218.790000 50237.010000 50264.130000 50196.680000 50200.410000 50248.890000 50214.500000 50244.170000
2021-02-24 03:00:00 50472.640000 50458.460000 50494.400000 50533.800000 50435.240000 50608.440000 50528.680000 50948.000000 50523.290000 50498.140000 50537.040000 50513.870000
2021-02-24 04:00:00 50987.940000 50851.640000 50934.950000 51019.750000 51023.200000 50889.740000 50914.280000 50892.810000 50900.800000 50942.650000 50917.060000 50927.850000
2021-02-24 05:00:00 50440.120000 50473.960000 50528.600000 50416.280000 50399.460000 50344.150000 50537.360000 nan 50383.990000 50513.990000 50421.090000 50455.610000
2021-02-24 06:00:00 49939.780000 50061.810000 49935.140000 49907.750000 49940.210000 49713.510000 50033.770000 49978.510000 50046.490000 49982.470000 49916.110000 49913.410000
2021-02-24 07:00:00 49974.240000 49996.280000 50034.860000 49944.960000 50030.400000 49899.140000 50032.960000 49680.100000 49861.580000 49959.620000 49994.270000 49962.540000
2021-02-24 08:00:00 50594.390000 50552.860000 50476.880000 50600.270000 50482.660000 50629.720000 50587.220000 50144.210000 50559.890000 50541.090000 50545.220000 50578.670000
2021-02-24 09:00:00 50902.710000 50934.150000 50901.640000 51014.430000 51005.570000 50887.440000 50947.530000 50884.020000 50842.080000 50901.000000 50987.740000 50911.780000

4) To display the VWMP df synthesis:¶

In [25]:
df_synthese_vwmp = compilated_dict['df_synthese_vwmp']
df_head = df_synthese_vwmp.head(10)

def highlight_min(s):
    """
    Highlights the minimum value in each row with a green background.
    Args:
        s (pandas.Series): A row from the DataFrame.
    Returns:
        list: A list of styles, with 'background-color: green' for the minimum value.
    """
    is_min = s == s.min()  # Identify the minimum value in the row
    return ['background-color: green' if v else '' for v in is_min]

# Apply the conditional styling to the top 10 rows of the DataFrame
styled_df = df_head.style.apply(highlight_min, axis=1)

# Convert the styled DataFrame to HTML and prepare the output
html_str = f"<h2>Results [VWMP] ({vwmp_type})</h2>"  # Header for the HTML output
html_str += styled_df.to_html(classes='scrollable-table', justify='left', escape=False)

# Display the styled HTML DataFrame
display(HTML(html_str))

Results [VWMP] (lower)

  stmp_vwmp (lower) lmax_vwmp (lower) gmni_vwmp (lower) itbi_vwmp (lower) okcn_vwmp (lower) bfnx_vwmp (lower) btrx_vwmp (lower) bfly_vwmp (lower) bnus_vwmp (lower) cbse_vwmp (lower) krkn_vwmp (lower) all_vwmp (lower)
timestamp                        
2021-02-24 00:00:00 47625.910000 47299.000000 48315.260000 47233.500000 47800.700000 48625.000000 48144.740000 47743.620000 47900.000000 48577.200000 48300.000000 48888.000000
2021-02-24 01:00:00 48915.440000 49275.000000 49101.000000 49700.000000 48876.620000 49834.000000 49880.700000 49777.910000 49234.790000 48703.580000 49302.500000 48946.350000
2021-02-24 02:00:00 50319.470000 50341.000000 50365.390000 50325.000000 50392.720000 50388.000000 50283.490000 49994.550000 50276.620000 50078.860000 50044.800000 50075.500000
2021-02-24 03:00:00 50898.120000 50365.500000 50656.810000 50937.250000 50970.650000 50534.000000 50488.860000 50948.000000 50211.690000 50466.570000 50306.200000 50314.070000
2021-02-24 04:00:00 50975.370000 51249.000000 51134.860000 50754.500000 50770.000000 50919.000000 50814.880000 51025.460000 51075.090000 50668.330000 50860.400000 50500.000000
2021-02-24 05:00:00 50215.150000 50216.000000 50954.350000 50498.750000 50186.140000 50420.000000 50136.440000 nan 50099.920000 50830.630000 50282.400000 50539.680000
2021-02-24 06:00:00 50476.720000 49878.500000 50092.000000 50047.000000 49689.230000 49662.000000 49823.590000 50016.680000 50439.660000 50170.680000 49613.000000 49873.160000
2021-02-24 07:00:00 50171.000000 49785.000000 50304.820000 49870.500000 49691.870000 49639.000000 50250.000000 49680.100000 49557.000000 50255.060000 50146.800000 49747.640000
2021-02-24 08:00:00 50493.970000 50870.500000 50665.680000 50461.750000 50555.450000 50600.000000 50659.680000 50410.650000 50868.010000 50184.440000 49922.900000 50200.000000
2021-02-24 09:00:00 50582.270000 50923.500000 51358.510000 50919.750000 51155.960000 50800.000000 51273.560000 50900.000000 50959.970000 50820.010000 51143.600000 50920.000000

4) To export the results in csv format:¶

In [ ]:
export_success = export_csv(compilated_dict, frequency, vwmp_type)